#  根据 token 找到 nuscene 的图像标签

from nuscenes.nuscenes import NuScenes
import os
from nuscenes.utils.color_map import get_colormap

# nuscenes 存放路径
nuscenes_data = "E:\\data\\3DpointCloud\\nuscenes\\nuscenes_mini"
nusc = NuScenes(version="v1.0-mini", dataroot=nuscenes_data, verbose=False)

spec_token = "f94199c2a589484d8e32dd6bf4931d4f"

my_sample_data = nusc.get("sample_data", spec_token)

my_sample = nusc.get("sample", my_sample_data["sample_token"])

# print("my_sample_data: ", my_sample_data)
# print("my_sample: ", my_sample)

my_predictions_bin_file = os.path.join('E:\\data\\3DpointCloud\\nuscenes\\nuscenes_mini\\lidarseg\\v1.0-mini', spec_token + '_lidarseg.bin')
# my_predictions_bin_file = os.path.join('D:\\resource\\code\\202507\\vis_nusc\\pred', spec_token + '_lidarseg.bin')

nusc.render_pointcloud_in_image(my_sample['token'],
                                pointsensor_channel='LIDAR_TOP',
                                camera_channel='CAM_BACK',
                                render_intensity=False,
                                show_lidarseg=True,
                                # filter_lidarseg_labels=[22, 23],s
                                show_lidarseg_legend=True,
                                lidarseg_preds_bin_path=my_predictions_bin_file)
